//
//  BottomBtn2.m
//  EducationAdminClient
//
//  Created by 孙添凤 on 17/1/18.
//  Copyright © 2017年 周佳兴. All rights reserved.
//

#import "BottomBtn2.h"
#import "Masonry.h"
#import "UIColor+CL.h"
@implementation BottomBtn2

-(instancetype)init{
    if(self==[super init]){
        
        //*** 用这个 view 的原因 是 想把 之前的 代码的 居中 布局修改成 更灵活的 方式
        self.btnSubView = [[UIView alloc]init];
        [self addSubview:self.btnSubView];
        self.btnImg =[[UIImageView alloc]init];
        
        
        [self.btnImg sizeToFit];
        [_btnSubView addSubview:self.btnImg];
        
        
        self.btnTitle =[[UILabel alloc]init];
        [_btnSubView addSubview:self.btnTitle];
        
        
        [self.btnImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.btnSubView.mas_left);
            make.centerY.equalTo(self.btnSubView.mas_centerY);
        }];
        
        [self.btnTitle mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.btnImg.mas_right).offset(8);
            make.centerY.equalTo(self.btnSubView.mas_centerY);
        }];
        
        [self.btnSubView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.btnImg.mas_left);
            make.right.equalTo(self.btnTitle.mas_right);
            make.top.equalTo(self.mas_top);
            make.bottom.equalTo(self.mas_bottom);
            make.centerX.equalTo(self.mas_centerX);
        }];

        //*** 将这三个 View sub view 用户 操作 交互 关闭 才能相应 对应的 按钮 view 的 点击事件
        self.btnImg.userInteractionEnabled = NO;
        self.btnTitle.userInteractionEnabled = NO;
        self.btnSubView.userInteractionEnabled = NO;

//        self.btnSubView.backgroundColor = [UIColor redColor];
        self.backgroundColor =[UIColor clearColor];
        
    }
    return self;
}

-(void)drawRect:(CGRect)rect{
    
     float width = rect.size.width;
    
    
    
//    self.btnImg.image =[UIImage imageNamed:@"edit"];
//    self.btnTitle.textColor =[UIColor colorWithHex:0x9c9c9c];

    
    
    self.btnTitle.font =[UIFont systemFontOfSize:14];
}

@end
